<?php
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg7.php" ?>
<?php include "ewmysql7.php" ?>
<?php include "phpfn7.php" ?>
<?php include "psacar_carinfo.php" ?>
<?php include "psacar_userinfo.php" ?>
<?php include "userfn7.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Create page object
$psacar_car_addopt = new cpsacar_car_addopt();
$Page =& $psacar_car_addopt;

// Page init
$psacar_car_addopt->Page_Init();

// Page main
$psacar_car_addopt->Page_Main();
?>
<script type="text/javascript">
<!--
var psacar_car_addopt = new ew_Page("psacar_car_addopt");

// page properties
psacar_car_addopt.PageID = "addopt"; // page ID
psacar_car_addopt.FormID = "fpsacar_caraddopt"; // form ID
var EW_PAGE_ID = psacar_car_addopt.PageID; // for backward compatibility

// extend page with ValidateForm function
psacar_car_addopt.ValidateForm = function(fobj) {
	return true; // ignore validation
}

//-->
</script>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$psacar_car_addopt->ShowMessage();
?>
<form name="fpsacar_caraddopt" id="fpsacar_caraddopt" action="psacar_caraddopt.php" method="post" onsubmit="return psacar_car_addopt.ValidateForm(this);">
<p>
<input type="hidden" name="t" id="t" value="psacar_car">
<input type="hidden" name="a_addopt" id="a_addopt" value="A">
<table class="ewTableAddOpt">
	<tr>
		<td><?php echo $psacar_car->dealer_id->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td><span id="el_dealer_id">
<select id="x_dealer_id" name="x_dealer_id" title="<?php echo $psacar_car->dealer_id->FldTitle() ?>"<?php echo $psacar_car->dealer_id->EditAttributes() ?>>
<?php
if (is_array($psacar_car->dealer_id->EditValue)) {
	$arwrk = $psacar_car->dealer_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_car->dealer_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span></td>
	</tr>
	<tr>
		<td><?php echo $psacar_car->series_id->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td><span id="el_series_id">
<select id="x_series_id" name="x_series_id" title="<?php echo $psacar_car->series_id->FldTitle() ?>"<?php echo $psacar_car->series_id->EditAttributes() ?>>
<?php
if (is_array($psacar_car->series_id->EditValue)) {
	$arwrk = $psacar_car->series_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_car->series_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span></td>
	</tr>
	<tr>
		<td><?php echo $psacar_car->external_color_id->FldCaption() ?></td>
		<td><span id="el_external_color_id">
<select id="x_external_color_id" name="x_external_color_id" title="<?php echo $psacar_car->external_color_id->FldTitle() ?>"<?php echo $psacar_car->external_color_id->EditAttributes() ?>>
<?php
if (is_array($psacar_car->external_color_id->EditValue)) {
	$arwrk = $psacar_car->external_color_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_car->external_color_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span></td>
	</tr>
	<tr>
		<td><?php echo $psacar_car->type_id->FldCaption() ?></td>
		<td><span id="el_type_id">
<select id="x_type_id" name="x_type_id" title="<?php echo $psacar_car->type_id->FldTitle() ?>"<?php echo $psacar_car->type_id->EditAttributes() ?>>
<?php
if (is_array($psacar_car->type_id->EditValue)) {
	$arwrk = $psacar_car->type_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_car->type_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span></td>
	</tr>
	<tr>
		<td><?php echo $psacar_car->category_id->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td><span id="el_category_id">
<select id="x_category_id" name="x_category_id" title="<?php echo $psacar_car->category_id->FldTitle() ?>"<?php echo $psacar_car->category_id->EditAttributes() ?>>
<?php
if (is_array($psacar_car->category_id->EditValue)) {
	$arwrk = $psacar_car->category_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_car->category_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span></td>
	</tr>
	<tr>
		<td><?php echo $psacar_car->price->FldCaption() ?></td>
		<td><span id="el_price">
<input type="text" name="x_price" id="x_price" title="<?php echo $psacar_car->price->FldTitle() ?>" size="30" value="<?php echo $psacar_car->price->EditValue ?>"<?php echo $psacar_car->price->EditAttributes() ?>>
</span></td>
	</tr>
	<tr>
		<td><?php echo $psacar_car->quality->FldCaption() ?></td>
		<td><span id="el_quality">
<input type="text" name="x_quality" id="x_quality" title="<?php echo $psacar_car->quality->FldTitle() ?>" size="30" value="<?php echo $psacar_car->quality->EditValue ?>"<?php echo $psacar_car->quality->EditAttributes() ?>>
</span></td>
	</tr>
	<tr>
		<td><?php echo $psacar_car->internal_color_id->FldCaption() ?></td>
		<td><span id="el_internal_color_id">
<select id="x_internal_color_id" name="x_internal_color_id" title="<?php echo $psacar_car->internal_color_id->FldTitle() ?>"<?php echo $psacar_car->internal_color_id->EditAttributes() ?>>
<?php
if (is_array($psacar_car->internal_color_id->EditValue)) {
	$arwrk = $psacar_car->internal_color_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_car->internal_color_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span></td>
	</tr>
	<tr>
		<td><?php echo $psacar_car->transmission->FldCaption() ?></td>
		<td><span id="el_transmission">
<select id="x_transmission" name="x_transmission" title="<?php echo $psacar_car->transmission->FldTitle() ?>"<?php echo $psacar_car->transmission->EditAttributes() ?>>
<?php
if (is_array($psacar_car->transmission->EditValue)) {
	$arwrk = $psacar_car->transmission->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_car->transmission->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span></td>
	</tr>
	<tr>
		<td><?php echo $psacar_car->legal->FldCaption() ?></td>
		<td><span id="el_legal">
<select id="x_legal" name="x_legal" title="<?php echo $psacar_car->legal->FldTitle() ?>"<?php echo $psacar_car->legal->EditAttributes() ?>>
<?php
if (is_array($psacar_car->legal->EditValue)) {
	$arwrk = $psacar_car->legal->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_car->legal->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span></td>
	</tr>
	<tr>
		<td><?php echo $psacar_car->import_tax->FldCaption() ?></td>
		<td><span id="el_import_tax">
<select id="x_import_tax" name="x_import_tax" title="<?php echo $psacar_car->import_tax->FldTitle() ?>"<?php echo $psacar_car->import_tax->EditAttributes() ?>>
<?php
if (is_array($psacar_car->import_tax->EditValue)) {
	$arwrk = $psacar_car->import_tax->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_car->import_tax->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span></td>
	</tr>
	<tr>
		<td><?php echo $psacar_car->drive_train->FldCaption() ?></td>
		<td><span id="el_drive_train">
<select id="x_drive_train" name="x_drive_train" title="<?php echo $psacar_car->drive_train->FldTitle() ?>"<?php echo $psacar_car->drive_train->EditAttributes() ?>>
<?php
if (is_array($psacar_car->drive_train->EditValue)) {
	$arwrk = $psacar_car->drive_train->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_car->drive_train->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span></td>
	</tr>
	<tr>
		<td><?php echo $psacar_car->door_count->FldCaption() ?></td>
		<td><span id="el_door_count">
<select id="x_door_count" name="x_door_count" title="<?php echo $psacar_car->door_count->FldTitle() ?>"<?php echo $psacar_car->door_count->EditAttributes() ?>>
<?php
if (is_array($psacar_car->door_count->EditValue)) {
	$arwrk = $psacar_car->door_count->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_car->door_count->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span></td>
	</tr>
	<tr>
		<td><?php echo $psacar_car->fuel->FldCaption() ?></td>
		<td><span id="el_fuel">
<div id="tp_x_fuel" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME; ?>"><input type="checkbox" name="x_fuel[]" id="x_fuel[]" title="<?php echo $psacar_car->fuel->FldTitle() ?>" value="{value}"<?php echo $psacar_car->fuel->EditAttributes() ?>></div>
<div id="dsl_x_fuel" repeatcolumn="5">
<?php
$arwrk = $psacar_car->fuel->EditValue;
if (is_array($arwrk)) {
	$armultiwrk= explode(",", strval($psacar_car->fuel->CurrentValue));
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = "";
		for ($ari = 0; $ari < count($armultiwrk); $ari++) {
			if (strval($arwrk[$rowcntwrk][0]) == trim(strval($armultiwrk[$ari]))) {
				$selwrk = " checked=\"checked\"";
				if ($selwrk <> "") $emptywrk = FALSE;
				break;
			}
		}

		// Note: No spacing within the LABEL tag
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<label><input type="checkbox" name="x_fuel[]" id="x_fuel[]" title="<?php echo $psacar_car->fuel->FldTitle() ?>" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $psacar_car->fuel->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
?>
</div>
</span></td>
	</tr>
	<tr>
		<td><?php echo $psacar_car->vehicle_type_id->FldCaption() ?></td>
		<td><span id="el_vehicle_type_id">
<select id="x_vehicle_type_id" name="x_vehicle_type_id" title="<?php echo $psacar_car->vehicle_type_id->FldTitle() ?>"<?php echo $psacar_car->vehicle_type_id->EditAttributes() ?>>
<?php
if (is_array($psacar_car->vehicle_type_id->EditValue)) {
	$arwrk = $psacar_car->vehicle_type_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_car->vehicle_type_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span></td>
	</tr>
	<tr>
		<td><?php echo $psacar_car->vehicle_id_number->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td><span id="el_vehicle_id_number">
<input type="text" name="x_vehicle_id_number" id="x_vehicle_id_number" title="<?php echo $psacar_car->vehicle_id_number->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $psacar_car->vehicle_id_number->EditValue ?>"<?php echo $psacar_car->vehicle_id_number->EditAttributes() ?>>
</span></td>
	</tr>
	<tr>
		<td><?php echo $psacar_car->created_date->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td><span id="el_created_date">
<input type="text" name="x_created_date" id="x_created_date" title="<?php echo $psacar_car->created_date->FldTitle() ?>" value="<?php echo $psacar_car->created_date->EditValue ?>"<?php echo $psacar_car->created_date->EditAttributes() ?>>
</span></td>
	</tr>
	<tr>
		<td><?php echo $psacar_car->modified_date->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td><span id="el_modified_date">
<input type="text" name="x_modified_date" id="x_modified_date" title="<?php echo $psacar_car->modified_date->FldTitle() ?>" value="<?php echo $psacar_car->modified_date->EditValue ?>"<?php echo $psacar_car->modified_date->EditAttributes() ?>>
</span></td>
	</tr>
</table>
<p>
</form>
<?php
$psacar_car_addopt->Page_Terminate();
?>
<?php

//
// Page class
//
class cpsacar_car_addopt {

	// Page ID
	var $PageID = 'addopt';

	// Table name
	var $TableName = 'psacar_car';

	// Page object name
	var $PageObjName = 'psacar_car_addopt';

	// Page name
	function PageName() {
		return ew_CurrentPage();
	}

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		global $psacar_car;
		if ($psacar_car->UseTokenInUrl) $PageUrl .= "t=" . $psacar_car->TableVar . "&"; // Add page token
		return $PageUrl;
	}

	// Page URLs
	var $AddUrl;
	var $EditUrl;
	var $CopyUrl;
	var $DeleteUrl;
	var $ViewUrl;
	var $ListUrl;

	// Export URLs
	var $ExportPrintUrl;
	var $ExportHtmlUrl;
	var $ExportExcelUrl;
	var $ExportWordUrl;
	var $ExportXmlUrl;
	var $ExportCsvUrl;

	// Update URLs
	var $InlineAddUrl;
	var $InlineCopyUrl;
	var $InlineEditUrl;
	var $GridAddUrl;
	var $GridEditUrl;
	var $MultiDeleteUrl;
	var $MultiUpdateUrl;

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Append
			$_SESSION[EW_SESSION_MESSAGE] .= "<br>" . $v;
		} else {
			$_SESSION[EW_SESSION_MESSAGE] = $v;
		}
	}

	// Show message
	function ShowMessage() {
		$sMessage = $this->getMessage();
		$this->Message_Showing($sMessage);
		if ($sMessage <> "") { // Message in Session, display
			echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}
	}

	// Validate page request
	function IsPageRequest() {
		global $objForm, $psacar_car;
		if ($psacar_car->UseTokenInUrl) {
			if ($objForm)
				return ($psacar_car->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($psacar_car->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

	//
	// Page class constructor
	//
	function cpsacar_car_addopt() {
		global $conn, $Language;

		// Language object
		$Language = new cLanguage();

		// Table object (psacar_car)
		$GLOBALS["psacar_car"] = new cpsacar_car();

		// Table object (psacar_user)
		$GLOBALS['psacar_user'] = new cpsacar_user();

		// Page ID
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'addopt', TRUE);

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'psacar_car', TRUE);

		// Start timer
		$GLOBALS["gsTimer"] = new cTimer();

		// Open connection
		$conn = ew_Connect();
	}

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
		global $psacar_car;

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}

		// Create form object
		$objForm = new cFormObj();

		// Global Page Loading event (in userfn*.php)
		Page_Loading();

		// Page Load event
		$this->Page_Load();
	}

	//
	// Page_Terminate
	//
	function Page_Terminate($url = "") {
		global $conn;

		// Page Unload event
		$this->Page_Unload();

		// Global Page Unloaded event (in userfn*.php)
		Page_Unloaded();

		 // Close connection
		$conn->Close();

		// Go to URL if specified
		$this->Page_Redirecting($url);
		if ($url <> "") {
			if (!EW_DEBUG_ENABLED && ob_get_length())
				ob_end_clean();
			header("Location: " . $url);
		}
		exit();
	}

	//
	// Page main
	//
	function Page_Main() {
		global $objForm, $Language, $gsFormError, $psacar_car;

		// Process form if post back
		if ($objForm->GetValue("a_addopt") <> "") {
			$psacar_car->CurrentAction = $objForm->GetValue("a_addopt"); // Get form action
			$this->LoadFormValues(); // Load form values

			// Validate form
			if (!$this->ValidateForm()) {
				$psacar_car->CurrentAction = "I"; // Form error, reset action
				$this->setMessage($gsFormError);
			}
		} else { // Not post back
			$psacar_car->CurrentAction = "I"; // Display blank record
			$this->LoadDefaultValues(); // Load default values
		}

		// Perform action based on action code
		switch ($psacar_car->CurrentAction) {
			case "I": // Blank record, no action required
				break;
			case "A": // Add new record
				$psacar_car->SendEmail = TRUE; // Send email on add success
				if ($this->AddRow()) { // Add successful
					$XMLDoc = new cXMLDocument("utf-8");
					$XMLDoc->AddRoot("root");
					$XMLDoc->AddRow("result");
					$XMLDoc->AddField("x_id", strval($psacar_car->id->DbValue));
					$XMLDoc->AddField("x_dealer_id", strval($psacar_car->dealer_id->FormValue));
					$XMLDoc->AddField("x_series_id", strval($psacar_car->series_id->FormValue));
					$XMLDoc->AddField("x_external_color_id", strval($psacar_car->external_color_id->FormValue));
					$XMLDoc->AddField("x_type_id", strval($psacar_car->type_id->FormValue));
					$XMLDoc->AddField("x_category_id", strval($psacar_car->category_id->FormValue));
					$XMLDoc->AddField("x_description", strval($psacar_car->description->FormValue));
					$XMLDoc->AddField("x_price", strval($psacar_car->price->FormValue));
					$XMLDoc->AddField("x_quality", strval($psacar_car->quality->FormValue));
					$XMLDoc->AddField("x_post_by", strval($psacar_car->post_by->FormValue));
					$XMLDoc->AddField("x_post_date", strval($psacar_car->post_date->FormValue));
					$XMLDoc->AddField("x_expiration_date", strval($psacar_car->expiration_date->FormValue));
					$XMLDoc->AddField("x_number_votes", strval($psacar_car->number_votes->FormValue));
					$XMLDoc->AddField("x_total_points", strval($psacar_car->total_points->FormValue));
					$XMLDoc->AddField("x_dec_avg", strval($psacar_car->dec_avg->FormValue));
					$XMLDoc->AddField("x_whole_avg", strval($psacar_car->whole_avg->FormValue));
					$XMLDoc->AddField("x_internal_color_id", strval($psacar_car->internal_color_id->FormValue));
					$XMLDoc->AddField("x_transmission", strval($psacar_car->transmission->FormValue));
					$XMLDoc->AddField("x_legal", strval($psacar_car->legal->FormValue));
					$XMLDoc->AddField("x_import_tax", strval($psacar_car->import_tax->FormValue));
					$XMLDoc->AddField("x_drive_train", strval($psacar_car->drive_train->FormValue));
					$XMLDoc->AddField("x_door_count", strval($psacar_car->door_count->FormValue));
					$XMLDoc->AddField("x_fuel", strval($psacar_car->fuel->FormValue));
					$XMLDoc->AddField("x_vat", strval($psacar_car->vat->FormValue));
					$XMLDoc->AddField("x_destinations", strval($psacar_car->destinations->FormValue));
					$XMLDoc->AddField("x_rent_type", strval($psacar_car->rent_type->FormValue));
					$XMLDoc->AddField("x_vehicle_type_id", strval($psacar_car->vehicle_type_id->FormValue));
					$XMLDoc->AddField("x_is_driver", strval($psacar_car->is_driver->FormValue));
					$XMLDoc->AddField("x_image", strval($psacar_car->image->FormValue));
					$XMLDoc->AddField("x_vehicle_id_number", strval($psacar_car->vehicle_id_number->FormValue));
					$XMLDoc->AddField("x_negotiate", strval($psacar_car->negotiate->FormValue));
					$XMLDoc->AddField("x_duration_type", strval($psacar_car->duration_type->FormValue));
					$XMLDoc->AddField("x_duration", strval($psacar_car->duration->FormValue));
					$XMLDoc->AddField("x_create_date", strval($psacar_car->create_date->FormValue));
					$XMLDoc->AddField("x_end_date", strval($psacar_car->end_date->FormValue));
					$XMLDoc->AddField("x_status", strval($psacar_car->status->FormValue));
					$XMLDoc->AddField("x_code", strval($psacar_car->code->FormValue));
					$XMLDoc->AddField("x_created_date", strval($psacar_car->created_date->FormValue));
					$XMLDoc->AddField("x_modified_date", strval($psacar_car->modified_date->FormValue));
					header("Content-Type: text/xml");
					echo $XMLDoc->XML();
					$this->Page_Terminate();
					exit();
				} else {
					$this->RestoreFormValues(); // Add failed, restore form values
				}
		}

		// Render row
		$psacar_car->RowType = EW_ROWTYPE_ADD; // Render add type
		$this->RenderRow();
	}

	// Get upload files
	function GetUploadFiles() {
		global $objForm, $psacar_car;

		// Get upload data
	}

	// Load default values
	function LoadDefaultValues() {
		global $psacar_car;
	}

	// Load form values
	function LoadFormValues() {

		// Load from form
		global $objForm, $psacar_car;
		$psacar_car->dealer_id->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_dealer_id")));
		$psacar_car->series_id->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_series_id")));
		$psacar_car->external_color_id->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_external_color_id")));
		$psacar_car->type_id->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_type_id")));
		$psacar_car->category_id->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_category_id")));
		$psacar_car->price->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_price")));
		$psacar_car->quality->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_quality")));
		$psacar_car->internal_color_id->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_internal_color_id")));
		$psacar_car->transmission->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_transmission")));
		$psacar_car->legal->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_legal")));
		$psacar_car->import_tax->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_import_tax")));
		$psacar_car->drive_train->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_drive_train")));
		$psacar_car->door_count->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_door_count")));
		$psacar_car->fuel->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_fuel")));
		$psacar_car->vehicle_type_id->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_vehicle_type_id")));
		$psacar_car->vehicle_id_number->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_vehicle_id_number")));
		$psacar_car->created_date->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_created_date")));
		$psacar_car->created_date->CurrentValue = ew_UnFormatDateTime($psacar_car->created_date->CurrentValue, 5);
		$psacar_car->modified_date->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_modified_date")));
		$psacar_car->modified_date->CurrentValue = ew_UnFormatDateTime($psacar_car->modified_date->CurrentValue, 5);
		$psacar_car->id->setFormValue(ew_ConvertFromUtf8($objForm->GetValue("x_id")));
	}

	// Restore form values
	function RestoreFormValues() {
		global $objForm, $psacar_car;
		$psacar_car->id->CurrentValue = ew_ConvertToUtf8($psacar_car->id->FormValue);
		$psacar_car->dealer_id->CurrentValue = ew_ConvertToUtf8($psacar_car->dealer_id->FormValue);
		$psacar_car->series_id->CurrentValue = ew_ConvertToUtf8($psacar_car->series_id->FormValue);
		$psacar_car->external_color_id->CurrentValue = ew_ConvertToUtf8($psacar_car->external_color_id->FormValue);
		$psacar_car->type_id->CurrentValue = ew_ConvertToUtf8($psacar_car->type_id->FormValue);
		$psacar_car->category_id->CurrentValue = ew_ConvertToUtf8($psacar_car->category_id->FormValue);
		$psacar_car->price->CurrentValue = ew_ConvertToUtf8($psacar_car->price->FormValue);
		$psacar_car->quality->CurrentValue = ew_ConvertToUtf8($psacar_car->quality->FormValue);
		$psacar_car->internal_color_id->CurrentValue = ew_ConvertToUtf8($psacar_car->internal_color_id->FormValue);
		$psacar_car->transmission->CurrentValue = ew_ConvertToUtf8($psacar_car->transmission->FormValue);
		$psacar_car->legal->CurrentValue = ew_ConvertToUtf8($psacar_car->legal->FormValue);
		$psacar_car->import_tax->CurrentValue = ew_ConvertToUtf8($psacar_car->import_tax->FormValue);
		$psacar_car->drive_train->CurrentValue = ew_ConvertToUtf8($psacar_car->drive_train->FormValue);
		$psacar_car->door_count->CurrentValue = ew_ConvertToUtf8($psacar_car->door_count->FormValue);
		$psacar_car->fuel->CurrentValue = ew_ConvertToUtf8($psacar_car->fuel->FormValue);
		$psacar_car->vehicle_type_id->CurrentValue = ew_ConvertToUtf8($psacar_car->vehicle_type_id->FormValue);
		$psacar_car->vehicle_id_number->CurrentValue = ew_ConvertToUtf8($psacar_car->vehicle_id_number->FormValue);
		$psacar_car->created_date->CurrentValue = ew_ConvertToUtf8($psacar_car->created_date->FormValue);
		$psacar_car->created_date->CurrentValue = ew_UnFormatDateTime($psacar_car->created_date->CurrentValue, 5);
		$psacar_car->modified_date->CurrentValue = ew_ConvertToUtf8($psacar_car->modified_date->FormValue);
		$psacar_car->modified_date->CurrentValue = ew_UnFormatDateTime($psacar_car->modified_date->CurrentValue, 5);
	}

	// Load row based on key values
	function LoadRow() {
		global $conn, $Security, $psacar_car;
		$sFilter = $psacar_car->KeyFilter();

		// Call Row Selecting event
		$psacar_car->Row_Selecting($sFilter);

		// Load SQL based on filter
		$psacar_car->CurrentFilter = $sFilter;
		$sSql = $psacar_car->SQL();
		$res = FALSE;
		$rs = ew_LoadRecordset($sSql);
		if ($rs && !$rs->EOF) {
			$res = TRUE;
			$this->LoadRowValues($rs); // Load row values

			// Call Row Selected event
			$psacar_car->Row_Selected($rs);
			$rs->Close();
		}
		return $res;
	}

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $psacar_car;
		$psacar_car->id->setDbValue($rs->fields('id'));
		$psacar_car->dealer_id->setDbValue($rs->fields('dealer_id'));
		$psacar_car->series_id->setDbValue($rs->fields('series_id'));
		$psacar_car->external_color_id->setDbValue($rs->fields('external_color_id'));
		$psacar_car->type_id->setDbValue($rs->fields('type_id'));
		$psacar_car->category_id->setDbValue($rs->fields('category_id'));
		$psacar_car->description->setDbValue($rs->fields('description'));
		$psacar_car->price->setDbValue($rs->fields('price'));
		$psacar_car->quality->setDbValue($rs->fields('quality'));
		$psacar_car->post_by->setDbValue($rs->fields('post_by'));
		$psacar_car->post_date->setDbValue($rs->fields('post_date'));
		$psacar_car->expiration_date->setDbValue($rs->fields('expiration_date'));
		$psacar_car->number_votes->setDbValue($rs->fields('number_votes'));
		$psacar_car->total_points->setDbValue($rs->fields('total_points'));
		$psacar_car->dec_avg->setDbValue($rs->fields('dec_avg'));
		$psacar_car->whole_avg->setDbValue($rs->fields('whole_avg'));
		$psacar_car->internal_color_id->setDbValue($rs->fields('internal_color_id'));
		$psacar_car->transmission->setDbValue($rs->fields('transmission'));
		$psacar_car->legal->setDbValue($rs->fields('legal'));
		$psacar_car->import_tax->setDbValue($rs->fields('import_tax'));
		$psacar_car->drive_train->setDbValue($rs->fields('drive_train'));
		$psacar_car->door_count->setDbValue($rs->fields('door_count'));
		$psacar_car->fuel->setDbValue($rs->fields('fuel'));
		$psacar_car->vat->setDbValue($rs->fields('vat'));
		$psacar_car->destinations->setDbValue($rs->fields('destinations'));
		$psacar_car->rent_type->setDbValue($rs->fields('rent_type'));
		$psacar_car->vehicle_type_id->setDbValue($rs->fields('vehicle_type_id'));
		$psacar_car->is_driver->setDbValue($rs->fields('is_driver'));
		$psacar_car->image->Upload->DbValue = $rs->fields('image');
		$psacar_car->vehicle_id_number->setDbValue($rs->fields('vehicle_id_number'));
		$psacar_car->negotiate->setDbValue($rs->fields('negotiate'));
		$psacar_car->duration_type->setDbValue($rs->fields('duration_type'));
		$psacar_car->duration->setDbValue($rs->fields('duration'));
		$psacar_car->create_date->setDbValue($rs->fields('create_date'));
		$psacar_car->end_date->setDbValue($rs->fields('end_date'));
		$psacar_car->status->setDbValue($rs->fields('status'));
		$psacar_car->code->setDbValue($rs->fields('code'));
		$psacar_car->created_date->setDbValue($rs->fields('created_date'));
		$psacar_car->modified_date->setDbValue($rs->fields('modified_date'));
	}

	// Render row values based on field settings
	function RenderRow() {
		global $conn, $Security, $Language, $psacar_car;

		// Initialize URLs
		// Call Row_Rendering event

		$psacar_car->Row_Rendering();

		// Common render codes for all row types
		// dealer_id

		$psacar_car->dealer_id->CellCssStyle = ""; $psacar_car->dealer_id->CellCssClass = "";
		$psacar_car->dealer_id->CellAttrs = array(); $psacar_car->dealer_id->ViewAttrs = array(); $psacar_car->dealer_id->EditAttrs = array();

		// series_id
		$psacar_car->series_id->CellCssStyle = ""; $psacar_car->series_id->CellCssClass = "";
		$psacar_car->series_id->CellAttrs = array(); $psacar_car->series_id->ViewAttrs = array(); $psacar_car->series_id->EditAttrs = array();

		// external_color_id
		$psacar_car->external_color_id->CellCssStyle = ""; $psacar_car->external_color_id->CellCssClass = "";
		$psacar_car->external_color_id->CellAttrs = array(); $psacar_car->external_color_id->ViewAttrs = array(); $psacar_car->external_color_id->EditAttrs = array();

		// type_id
		$psacar_car->type_id->CellCssStyle = ""; $psacar_car->type_id->CellCssClass = "";
		$psacar_car->type_id->CellAttrs = array(); $psacar_car->type_id->ViewAttrs = array(); $psacar_car->type_id->EditAttrs = array();

		// category_id
		$psacar_car->category_id->CellCssStyle = ""; $psacar_car->category_id->CellCssClass = "";
		$psacar_car->category_id->CellAttrs = array(); $psacar_car->category_id->ViewAttrs = array(); $psacar_car->category_id->EditAttrs = array();

		// price
		$psacar_car->price->CellCssStyle = ""; $psacar_car->price->CellCssClass = "";
		$psacar_car->price->CellAttrs = array(); $psacar_car->price->ViewAttrs = array(); $psacar_car->price->EditAttrs = array();

		// quality
		$psacar_car->quality->CellCssStyle = ""; $psacar_car->quality->CellCssClass = "";
		$psacar_car->quality->CellAttrs = array(); $psacar_car->quality->ViewAttrs = array(); $psacar_car->quality->EditAttrs = array();

		// internal_color_id
		$psacar_car->internal_color_id->CellCssStyle = ""; $psacar_car->internal_color_id->CellCssClass = "";
		$psacar_car->internal_color_id->CellAttrs = array(); $psacar_car->internal_color_id->ViewAttrs = array(); $psacar_car->internal_color_id->EditAttrs = array();

		// transmission
		$psacar_car->transmission->CellCssStyle = ""; $psacar_car->transmission->CellCssClass = "";
		$psacar_car->transmission->CellAttrs = array(); $psacar_car->transmission->ViewAttrs = array(); $psacar_car->transmission->EditAttrs = array();

		// legal
		$psacar_car->legal->CellCssStyle = ""; $psacar_car->legal->CellCssClass = "";
		$psacar_car->legal->CellAttrs = array(); $psacar_car->legal->ViewAttrs = array(); $psacar_car->legal->EditAttrs = array();

		// import_tax
		$psacar_car->import_tax->CellCssStyle = ""; $psacar_car->import_tax->CellCssClass = "";
		$psacar_car->import_tax->CellAttrs = array(); $psacar_car->import_tax->ViewAttrs = array(); $psacar_car->import_tax->EditAttrs = array();

		// drive_train
		$psacar_car->drive_train->CellCssStyle = ""; $psacar_car->drive_train->CellCssClass = "";
		$psacar_car->drive_train->CellAttrs = array(); $psacar_car->drive_train->ViewAttrs = array(); $psacar_car->drive_train->EditAttrs = array();

		// door_count
		$psacar_car->door_count->CellCssStyle = ""; $psacar_car->door_count->CellCssClass = "";
		$psacar_car->door_count->CellAttrs = array(); $psacar_car->door_count->ViewAttrs = array(); $psacar_car->door_count->EditAttrs = array();

		// fuel
		$psacar_car->fuel->CellCssStyle = ""; $psacar_car->fuel->CellCssClass = "";
		$psacar_car->fuel->CellAttrs = array(); $psacar_car->fuel->ViewAttrs = array(); $psacar_car->fuel->EditAttrs = array();

		// vehicle_type_id
		$psacar_car->vehicle_type_id->CellCssStyle = ""; $psacar_car->vehicle_type_id->CellCssClass = "";
		$psacar_car->vehicle_type_id->CellAttrs = array(); $psacar_car->vehicle_type_id->ViewAttrs = array(); $psacar_car->vehicle_type_id->EditAttrs = array();

		// vehicle_id_number
		$psacar_car->vehicle_id_number->CellCssStyle = ""; $psacar_car->vehicle_id_number->CellCssClass = "";
		$psacar_car->vehicle_id_number->CellAttrs = array(); $psacar_car->vehicle_id_number->ViewAttrs = array(); $psacar_car->vehicle_id_number->EditAttrs = array();

		// created_date
		$psacar_car->created_date->CellCssStyle = ""; $psacar_car->created_date->CellCssClass = "";
		$psacar_car->created_date->CellAttrs = array(); $psacar_car->created_date->ViewAttrs = array(); $psacar_car->created_date->EditAttrs = array();

		// modified_date
		$psacar_car->modified_date->CellCssStyle = ""; $psacar_car->modified_date->CellCssClass = "";
		$psacar_car->modified_date->CellAttrs = array(); $psacar_car->modified_date->ViewAttrs = array(); $psacar_car->modified_date->EditAttrs = array();
		if ($psacar_car->RowType == EW_ROWTYPE_VIEW) { // View row

			// dealer_id
			if (strval($psacar_car->dealer_id->CurrentValue) <> "") {
				$sFilterWrk = "`id` = " . ew_AdjustSql($psacar_car->dealer_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `name` FROM `psacar_member`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$psacar_car->dealer_id->ViewValue = $rswrk->fields('name');
					$rswrk->Close();
				} else {
					$psacar_car->dealer_id->ViewValue = $psacar_car->dealer_id->CurrentValue;
				}
			} else {
				$psacar_car->dealer_id->ViewValue = NULL;
			}
			$psacar_car->dealer_id->CssStyle = "";
			$psacar_car->dealer_id->CssClass = "";
			$psacar_car->dealer_id->ViewCustomAttributes = "";

			// series_id
			if (strval($psacar_car->series_id->CurrentValue) <> "") {
				$sFilterWrk = "psacar_series.id = " . ew_AdjustSql($psacar_car->series_id->CurrentValue) . "";
			$sSqlWrk = "SELECT Concat(psacar_make.name, \" - \", psacar_model.name, \" - \", psacar_color.color) AS `make_model_color` FROM psacar_make INNER JOIN psacar_model ON psacar_make.id = psacar_model.make_id INNER JOIN psacar_series ON psacar_model.id = psacar_series.model_id INNER JOIN psacar_color ON psacar_color.id = psacar_series.color_id";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$psacar_car->series_id->ViewValue = $rswrk->fields('make_model_color');
					$rswrk->Close();
				} else {
					$psacar_car->series_id->ViewValue = $psacar_car->series_id->CurrentValue;
				}
			} else {
				$psacar_car->series_id->ViewValue = NULL;
			}
			$psacar_car->series_id->CssStyle = "";
			$psacar_car->series_id->CssClass = "";
			$psacar_car->series_id->ViewCustomAttributes = "";

			// external_color_id
			if (strval($psacar_car->external_color_id->CurrentValue) <> "") {
				$sFilterWrk = "`id` = " . ew_AdjustSql($psacar_car->external_color_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `color` FROM `psacar_color`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$psacar_car->external_color_id->ViewValue = $rswrk->fields('color');
					$rswrk->Close();
				} else {
					$psacar_car->external_color_id->ViewValue = $psacar_car->external_color_id->CurrentValue;
				}
			} else {
				$psacar_car->external_color_id->ViewValue = NULL;
			}
			$psacar_car->external_color_id->CssStyle = "";
			$psacar_car->external_color_id->CssClass = "";
			$psacar_car->external_color_id->ViewCustomAttributes = "";

			// type_id
			if (strval($psacar_car->type_id->CurrentValue) <> "") {
				$sFilterWrk = "`id` = " . ew_AdjustSql($psacar_car->type_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `name` FROM `psacar_car_type`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$psacar_car->type_id->ViewValue = $rswrk->fields('name');
					$rswrk->Close();
				} else {
					$psacar_car->type_id->ViewValue = $psacar_car->type_id->CurrentValue;
				}
			} else {
				$psacar_car->type_id->ViewValue = NULL;
			}
			$psacar_car->type_id->CssStyle = "";
			$psacar_car->type_id->CssClass = "";
			$psacar_car->type_id->ViewCustomAttributes = "";

			// category_id
			if (strval($psacar_car->category_id->CurrentValue) <> "") {
				$sFilterWrk = "`category_id` = " . ew_AdjustSql($psacar_car->category_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `category_name` FROM `psacar_category`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$psacar_car->category_id->ViewValue = $rswrk->fields('category_name');
					$rswrk->Close();
				} else {
					$psacar_car->category_id->ViewValue = $psacar_car->category_id->CurrentValue;
				}
			} else {
				$psacar_car->category_id->ViewValue = NULL;
			}
			$psacar_car->category_id->CssStyle = "";
			$psacar_car->category_id->CssClass = "";
			$psacar_car->category_id->ViewCustomAttributes = "";

			// price
			$psacar_car->price->ViewValue = $psacar_car->price->CurrentValue;
			$psacar_car->price->CssStyle = "";
			$psacar_car->price->CssClass = "";
			$psacar_car->price->ViewCustomAttributes = "";

			// quality
			$psacar_car->quality->ViewValue = $psacar_car->quality->CurrentValue;
			if (strval($psacar_car->quality->CurrentValue) <> "") {
				$sFilterWrk = "`code` = " . ew_AdjustSql($psacar_car->quality->CurrentValue) . "";
			$sSqlWrk = "SELECT `mileage` FROM `psacar_mileage`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$psacar_car->quality->ViewValue = $rswrk->fields('mileage');
					$rswrk->Close();
				} else {
					$psacar_car->quality->ViewValue = $psacar_car->quality->CurrentValue;
				}
			} else {
				$psacar_car->quality->ViewValue = NULL;
			}
			$psacar_car->quality->CssStyle = "";
			$psacar_car->quality->CssClass = "";
			$psacar_car->quality->ViewCustomAttributes = "";

			// internal_color_id
			if (strval($psacar_car->internal_color_id->CurrentValue) <> "") {
				$sFilterWrk = "`id` = " . ew_AdjustSql($psacar_car->internal_color_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `color` FROM `psacar_color`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$psacar_car->internal_color_id->ViewValue = $rswrk->fields('color');
					$rswrk->Close();
				} else {
					$psacar_car->internal_color_id->ViewValue = $psacar_car->internal_color_id->CurrentValue;
				}
			} else {
				$psacar_car->internal_color_id->ViewValue = NULL;
			}
			$psacar_car->internal_color_id->CssStyle = "";
			$psacar_car->internal_color_id->CssClass = "";
			$psacar_car->internal_color_id->ViewCustomAttributes = "";

			// transmission
			if (strval($psacar_car->transmission->CurrentValue) <> "") {
				switch ($psacar_car->transmission->CurrentValue) {
					case "0":
						$psacar_car->transmission->ViewValue = "Manual";
						break;
					case "1":
						$psacar_car->transmission->ViewValue = "Automatic";
						break;
					case "2":
						$psacar_car->transmission->ViewValue = "Auto/manual";
						break;
					case "3":
						$psacar_car->transmission->ViewValue = "Others";
						break;
					default:
						$psacar_car->transmission->ViewValue = $psacar_car->transmission->CurrentValue;
				}
			} else {
				$psacar_car->transmission->ViewValue = NULL;
			}
			$psacar_car->transmission->CssStyle = "";
			$psacar_car->transmission->CssClass = "";
			$psacar_car->transmission->ViewCustomAttributes = "";

			// legal
			if (strval($psacar_car->legal->CurrentValue) <> "") {
				switch ($psacar_car->legal->CurrentValue) {
					case "0":
						$psacar_car->legal->ViewValue = "Owner transfer fee included";
						break;
					case "1":
						$psacar_car->legal->ViewValue = "Owner transfer fee not included";
						break;
					case "2":
						$psacar_car->legal->ViewValue = "Others";
						break;
					default:
						$psacar_car->legal->ViewValue = $psacar_car->legal->CurrentValue;
				}
			} else {
				$psacar_car->legal->ViewValue = NULL;
			}
			$psacar_car->legal->CssStyle = "";
			$psacar_car->legal->CssClass = "";
			$psacar_car->legal->ViewCustomAttributes = "";

			// import_tax
			if (strval($psacar_car->import_tax->CurrentValue) <> "") {
				switch ($psacar_car->import_tax->CurrentValue) {
					case "0":
						$psacar_car->import_tax->ViewValue = "Yes";
						break;
					case "1":
						$psacar_car->import_tax->ViewValue = "No";
						break;
					case "2":
						$psacar_car->import_tax->ViewValue = "Other";
						break;
					default:
						$psacar_car->import_tax->ViewValue = $psacar_car->import_tax->CurrentValue;
				}
			} else {
				$psacar_car->import_tax->ViewValue = NULL;
			}
			$psacar_car->import_tax->CssStyle = "";
			$psacar_car->import_tax->CssClass = "";
			$psacar_car->import_tax->ViewCustomAttributes = "";

			// drive_train
			if (strval($psacar_car->drive_train->CurrentValue) <> "") {
				switch ($psacar_car->drive_train->CurrentValue) {
					case "0":
						$psacar_car->drive_train->ViewValue = "2WD";
						break;
					case "1":
						$psacar_car->drive_train->ViewValue = "4WD";
						break;
					case "2":
						$psacar_car->drive_train->ViewValue = "FWD";
						break;
					case "3":
						$psacar_car->drive_train->ViewValue = "RWD";
						break;
					case "4":
						$psacar_car->drive_train->ViewValue = "Others";
						break;
					default:
						$psacar_car->drive_train->ViewValue = $psacar_car->drive_train->CurrentValue;
				}
			} else {
				$psacar_car->drive_train->ViewValue = NULL;
			}
			$psacar_car->drive_train->CssStyle = "";
			$psacar_car->drive_train->CssClass = "";
			$psacar_car->drive_train->ViewCustomAttributes = "";

			// door_count
			if (strval($psacar_car->door_count->CurrentValue) <> "") {
				$sFilterWrk = "`code` = " . ew_AdjustSql($psacar_car->door_count->CurrentValue) . "";
			$sSqlWrk = "SELECT `doorcount` FROM `psacar_doorcount`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$psacar_car->door_count->ViewValue = $rswrk->fields('doorcount');
					$rswrk->Close();
				} else {
					$psacar_car->door_count->ViewValue = $psacar_car->door_count->CurrentValue;
				}
			} else {
				$psacar_car->door_count->ViewValue = NULL;
			}
			$psacar_car->door_count->CssStyle = "";
			$psacar_car->door_count->CssClass = "";
			$psacar_car->door_count->ViewCustomAttributes = "";

			// fuel
			if (strval($psacar_car->fuel->CurrentValue) <> "") {
				$arwrk = explode(",", $psacar_car->fuel->CurrentValue);
				$sFilterWrk = "";
				foreach ($arwrk as $wrk) {
					if ($sFilterWrk <> "") $sFilterWrk .= " OR ";
					$sFilterWrk .= "`id` = " . ew_AdjustSql(trim($wrk)) . "";
				}	
			$sSqlWrk = "SELECT `fuel` FROM `psacar_fuel`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$psacar_car->fuel->ViewValue = "";
					$ari = 0;
					while (!$rswrk->EOF) {
						$psacar_car->fuel->ViewValue .= $rswrk->fields('fuel');
						$rswrk->MoveNext();
						if (!$rswrk->EOF) $psacar_car->fuel->ViewValue .= ew_ViewOptionSeparator($ari); // Separate Options
						$ari++;
					}
					$rswrk->Close();
				} else {
					$psacar_car->fuel->ViewValue = $psacar_car->fuel->CurrentValue;
				}
			} else {
				$psacar_car->fuel->ViewValue = NULL;
			}
			$psacar_car->fuel->CssStyle = "";
			$psacar_car->fuel->CssClass = "";
			$psacar_car->fuel->ViewCustomAttributes = "";

			// vehicle_type_id
			if (strval($psacar_car->vehicle_type_id->CurrentValue) <> "") {
				switch ($psacar_car->vehicle_type_id->CurrentValue) {
					case "0":
						$psacar_car->vehicle_type_id->ViewValue = "Buy";
						break;
					case "1":
						$psacar_car->vehicle_type_id->ViewValue = "Sale";
						break;
					case "2":
						$psacar_car->vehicle_type_id->ViewValue = "Rent";
						break;
					default:
						$psacar_car->vehicle_type_id->ViewValue = $psacar_car->vehicle_type_id->CurrentValue;
				}
			} else {
				$psacar_car->vehicle_type_id->ViewValue = NULL;
			}
			$psacar_car->vehicle_type_id->CssStyle = "";
			$psacar_car->vehicle_type_id->CssClass = "";
			$psacar_car->vehicle_type_id->ViewCustomAttributes = "";

			// vehicle_id_number
			$psacar_car->vehicle_id_number->ViewValue = $psacar_car->vehicle_id_number->CurrentValue;
			$psacar_car->vehicle_id_number->CssStyle = "";
			$psacar_car->vehicle_id_number->CssClass = "";
			$psacar_car->vehicle_id_number->ViewCustomAttributes = "";

			// create_date
			$psacar_car->create_date->ViewValue = $psacar_car->create_date->CurrentValue;
			$psacar_car->create_date->ViewValue = ew_FormatDateTime($psacar_car->create_date->ViewValue, 5);
			$psacar_car->create_date->CssStyle = "";
			$psacar_car->create_date->CssClass = "";
			$psacar_car->create_date->ViewCustomAttributes = "";

			// end_date
			$psacar_car->end_date->ViewValue = $psacar_car->end_date->CurrentValue;
			$psacar_car->end_date->ViewValue = ew_FormatDateTime($psacar_car->end_date->ViewValue, 5);
			$psacar_car->end_date->CssStyle = "";
			$psacar_car->end_date->CssClass = "";
			$psacar_car->end_date->ViewCustomAttributes = "";

			// status
			if (strval($psacar_car->status->CurrentValue) <> "") {
				switch ($psacar_car->status->CurrentValue) {
					case "0":
						$psacar_car->status->ViewValue = "Pendding";
						break;
					case "1":
						$psacar_car->status->ViewValue = "Approved";
						break;
					case "2":
						$psacar_car->status->ViewValue = "Deleted";
						break;
					default:
						$psacar_car->status->ViewValue = $psacar_car->status->CurrentValue;
				}
			} else {
				$psacar_car->status->ViewValue = NULL;
			}
			$psacar_car->status->CssStyle = "";
			$psacar_car->status->CssClass = "";
			$psacar_car->status->ViewCustomAttributes = "";

			// code
			$psacar_car->code->ViewValue = $psacar_car->code->CurrentValue;
			$psacar_car->code->CssStyle = "";
			$psacar_car->code->CssClass = "";
			$psacar_car->code->ViewCustomAttributes = "";

			// created_date
			$psacar_car->created_date->ViewValue = $psacar_car->created_date->CurrentValue;
			$psacar_car->created_date->ViewValue = ew_FormatDateTime($psacar_car->created_date->ViewValue, 5);
			$psacar_car->created_date->CssStyle = "";
			$psacar_car->created_date->CssClass = "";
			$psacar_car->created_date->ViewCustomAttributes = "";

			// modified_date
			$psacar_car->modified_date->ViewValue = $psacar_car->modified_date->CurrentValue;
			$psacar_car->modified_date->ViewValue = ew_FormatDateTime($psacar_car->modified_date->ViewValue, 5);
			$psacar_car->modified_date->CssStyle = "";
			$psacar_car->modified_date->CssClass = "";
			$psacar_car->modified_date->ViewCustomAttributes = "";

			// dealer_id
			$psacar_car->dealer_id->HrefValue = "";
			$psacar_car->dealer_id->TooltipValue = "";

			// series_id
			$psacar_car->series_id->HrefValue = "";
			$psacar_car->series_id->TooltipValue = "";

			// external_color_id
			$psacar_car->external_color_id->HrefValue = "";
			$psacar_car->external_color_id->TooltipValue = "";

			// type_id
			$psacar_car->type_id->HrefValue = "";
			$psacar_car->type_id->TooltipValue = "";

			// category_id
			$psacar_car->category_id->HrefValue = "";
			$psacar_car->category_id->TooltipValue = "";

			// price
			$psacar_car->price->HrefValue = "";
			$psacar_car->price->TooltipValue = "";

			// quality
			$psacar_car->quality->HrefValue = "";
			$psacar_car->quality->TooltipValue = "";

			// internal_color_id
			$psacar_car->internal_color_id->HrefValue = "";
			$psacar_car->internal_color_id->TooltipValue = "";

			// transmission
			$psacar_car->transmission->HrefValue = "";
			$psacar_car->transmission->TooltipValue = "";

			// legal
			$psacar_car->legal->HrefValue = "";
			$psacar_car->legal->TooltipValue = "";

			// import_tax
			$psacar_car->import_tax->HrefValue = "";
			$psacar_car->import_tax->TooltipValue = "";

			// drive_train
			$psacar_car->drive_train->HrefValue = "";
			$psacar_car->drive_train->TooltipValue = "";

			// door_count
			$psacar_car->door_count->HrefValue = "";
			$psacar_car->door_count->TooltipValue = "";

			// fuel
			$psacar_car->fuel->HrefValue = "";
			$psacar_car->fuel->TooltipValue = "";

			// vehicle_type_id
			$psacar_car->vehicle_type_id->HrefValue = "";
			$psacar_car->vehicle_type_id->TooltipValue = "";

			// vehicle_id_number
			$psacar_car->vehicle_id_number->HrefValue = "";
			$psacar_car->vehicle_id_number->TooltipValue = "";

			// created_date
			$psacar_car->created_date->HrefValue = "";
			$psacar_car->created_date->TooltipValue = "";

			// modified_date
			$psacar_car->modified_date->HrefValue = "";
			$psacar_car->modified_date->TooltipValue = "";
		} elseif ($psacar_car->RowType == EW_ROWTYPE_ADD) { // Add row

			// dealer_id
			$psacar_car->dealer_id->EditCustomAttributes = "";
				$sFilterWrk = "";
			$sSqlWrk = "SELECT `id`, `name`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `psacar_member`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$psacar_car->dealer_id->EditValue = $arwrk;

			// series_id
			$psacar_car->series_id->EditCustomAttributes = "";
				$sFilterWrk = "";
			$sSqlWrk = "SELECT psacar_series.id, Concat(psacar_make.name, \" - \", psacar_model.name, \" - \", psacar_color.color), '' AS Disp2Fld, '' AS SelectFilterFld FROM psacar_make INNER JOIN psacar_model ON psacar_make.id = psacar_model.make_id INNER JOIN psacar_series ON psacar_model.id = psacar_series.model_id INNER JOIN psacar_color ON psacar_color.id = psacar_series.color_id";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$psacar_car->series_id->EditValue = $arwrk;

			// external_color_id
			$psacar_car->external_color_id->EditCustomAttributes = "";
				$sFilterWrk = "";
			$sSqlWrk = "SELECT `id`, `color`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `psacar_color`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$psacar_car->external_color_id->EditValue = $arwrk;

			// type_id
			$psacar_car->type_id->EditCustomAttributes = "";
				$sFilterWrk = "";
			$sSqlWrk = "SELECT `id`, `name`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `psacar_car_type`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$psacar_car->type_id->EditValue = $arwrk;

			// category_id
			$psacar_car->category_id->EditCustomAttributes = "";
				$sFilterWrk = "";
			$sSqlWrk = "SELECT `category_id`, `category_name`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `psacar_category`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$psacar_car->category_id->EditValue = $arwrk;

			// price
			$psacar_car->price->EditCustomAttributes = "";
			$psacar_car->price->EditValue = ew_HtmlEncode($psacar_car->price->CurrentValue);

			// quality
			$psacar_car->quality->EditCustomAttributes = "";
			$psacar_car->quality->EditValue = ew_HtmlEncode($psacar_car->quality->CurrentValue);
			if (strval($psacar_car->quality->CurrentValue) <> "") {
				$sFilterWrk = "`code` = " . ew_AdjustSql($psacar_car->quality->CurrentValue) . "";
			$sSqlWrk = "SELECT `mileage` FROM `psacar_mileage`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$psacar_car->quality->EditValue = $rswrk->fields('mileage');
					$rswrk->Close();
				} else {
					$psacar_car->quality->EditValue = $psacar_car->quality->CurrentValue;
				}
			} else {
				$psacar_car->quality->EditValue = NULL;
			}

			// internal_color_id
			$psacar_car->internal_color_id->EditCustomAttributes = "";
				$sFilterWrk = "";
			$sSqlWrk = "SELECT `id`, `color`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `psacar_color`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$psacar_car->internal_color_id->EditValue = $arwrk;

			// transmission
			$psacar_car->transmission->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array("0", "Manual");
			$arwrk[] = array("1", "Automatic");
			$arwrk[] = array("2", "Auto/manual");
			$arwrk[] = array("3", "Others");
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$psacar_car->transmission->EditValue = $arwrk;

			// legal
			$psacar_car->legal->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array("0", "Owner transfer fee included");
			$arwrk[] = array("1", "Owner transfer fee not included");
			$arwrk[] = array("2", "Others");
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$psacar_car->legal->EditValue = $arwrk;

			// import_tax
			$psacar_car->import_tax->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array("0", "Yes");
			$arwrk[] = array("1", "No");
			$arwrk[] = array("2", "Other");
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$psacar_car->import_tax->EditValue = $arwrk;

			// drive_train
			$psacar_car->drive_train->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array("0", "2WD");
			$arwrk[] = array("1", "4WD");
			$arwrk[] = array("2", "FWD");
			$arwrk[] = array("3", "RWD");
			$arwrk[] = array("4", "Others");
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$psacar_car->drive_train->EditValue = $arwrk;

			// door_count
			$psacar_car->door_count->EditCustomAttributes = "";
				$sFilterWrk = "";
			$sSqlWrk = "SELECT `code`, `doorcount`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `psacar_doorcount`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$psacar_car->door_count->EditValue = $arwrk;

			// fuel
			$psacar_car->fuel->EditCustomAttributes = "";
				$sFilterWrk = "";
			$sSqlWrk = "SELECT `id`, `fuel`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `psacar_fuel`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			$psacar_car->fuel->EditValue = $arwrk;

			// vehicle_type_id
			$psacar_car->vehicle_type_id->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array("0", "Buy");
			$arwrk[] = array("1", "Sale");
			$arwrk[] = array("2", "Rent");
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$psacar_car->vehicle_type_id->EditValue = $arwrk;

			// vehicle_id_number
			$psacar_car->vehicle_id_number->EditCustomAttributes = "";
			$psacar_car->vehicle_id_number->EditValue = ew_HtmlEncode($psacar_car->vehicle_id_number->CurrentValue);

			// created_date
			$psacar_car->created_date->EditCustomAttributes = "";
			$psacar_car->created_date->EditValue = ew_HtmlEncode(ew_FormatDateTime($psacar_car->created_date->CurrentValue, 5));

			// modified_date
			$psacar_car->modified_date->EditCustomAttributes = "";
			$psacar_car->modified_date->EditValue = ew_HtmlEncode(ew_FormatDateTime($psacar_car->modified_date->CurrentValue, 5));
		}

		// Call Row Rendered event
		if ($psacar_car->RowType <> EW_ROWTYPE_AGGREGATEINIT)
			$psacar_car->Row_Rendered();
	}

	// Validate form
	function ValidateForm() {
		global $Language, $gsFormError, $psacar_car;

		// Initialize form error message
		$gsFormError = "";
		if (!is_null($psacar_car->dealer_id->FormValue) && $psacar_car->dealer_id->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $psacar_car->dealer_id->FldCaption();
		}
		if (!is_null($psacar_car->series_id->FormValue) && $psacar_car->series_id->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $psacar_car->series_id->FldCaption();
		}
		if (!is_null($psacar_car->category_id->FormValue) && $psacar_car->category_id->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $psacar_car->category_id->FldCaption();
		}
		if (!ew_CheckNumber($psacar_car->price->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $psacar_car->price->FldErrMsg();
		}
		if (!ew_CheckInteger($psacar_car->quality->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $psacar_car->quality->FldErrMsg();
		}
		if (!is_null($psacar_car->vehicle_id_number->FormValue) && $psacar_car->vehicle_id_number->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $psacar_car->vehicle_id_number->FldCaption();
		}
		if (!ew_CheckDate($psacar_car->created_date->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $psacar_car->created_date->FldErrMsg();
		}
		if (!ew_CheckDate($psacar_car->modified_date->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $psacar_car->modified_date->FldErrMsg();
		}

		// Return validate result
		$ValidateForm = ($gsFormError == "");

		// Call Form_CustomValidate event
		$sFormCustomError = "";
		$ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
		if ($sFormCustomError <> "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $sFormCustomError;
		}
		return $ValidateForm;
	}

	// Add record
	function AddRow() {
		global $conn, $Language, $Security, $psacar_car;
		$rsnew = array();

		// dealer_id
		$psacar_car->dealer_id->SetDbValueDef($rsnew, $psacar_car->dealer_id->CurrentValue, 0, FALSE);

		// series_id
		$psacar_car->series_id->SetDbValueDef($rsnew, $psacar_car->series_id->CurrentValue, 0, FALSE);

		// external_color_id
		$psacar_car->external_color_id->SetDbValueDef($rsnew, $psacar_car->external_color_id->CurrentValue, NULL, FALSE);

		// type_id
		$psacar_car->type_id->SetDbValueDef($rsnew, $psacar_car->type_id->CurrentValue, NULL, FALSE);

		// category_id
		$psacar_car->category_id->SetDbValueDef($rsnew, $psacar_car->category_id->CurrentValue, 0, FALSE);

		// price
		$psacar_car->price->SetDbValueDef($rsnew, $psacar_car->price->CurrentValue, NULL, FALSE);

		// quality
		$psacar_car->quality->SetDbValueDef($rsnew, $psacar_car->quality->CurrentValue, NULL, FALSE);

		// internal_color_id
		$psacar_car->internal_color_id->SetDbValueDef($rsnew, $psacar_car->internal_color_id->CurrentValue, NULL, FALSE);

		// transmission
		$psacar_car->transmission->SetDbValueDef($rsnew, $psacar_car->transmission->CurrentValue, NULL, FALSE);

		// legal
		$psacar_car->legal->SetDbValueDef($rsnew, $psacar_car->legal->CurrentValue, NULL, FALSE);

		// import_tax
		$psacar_car->import_tax->SetDbValueDef($rsnew, $psacar_car->import_tax->CurrentValue, NULL, FALSE);

		// drive_train
		$psacar_car->drive_train->SetDbValueDef($rsnew, $psacar_car->drive_train->CurrentValue, NULL, FALSE);

		// door_count
		$psacar_car->door_count->SetDbValueDef($rsnew, $psacar_car->door_count->CurrentValue, NULL, FALSE);

		// fuel
		$psacar_car->fuel->SetDbValueDef($rsnew, $psacar_car->fuel->CurrentValue, NULL, FALSE);

		// vehicle_type_id
		$psacar_car->vehicle_type_id->SetDbValueDef($rsnew, $psacar_car->vehicle_type_id->CurrentValue, NULL, FALSE);

		// vehicle_id_number
		$psacar_car->vehicle_id_number->SetDbValueDef($rsnew, $psacar_car->vehicle_id_number->CurrentValue, "", FALSE);

		// created_date
		$psacar_car->created_date->SetDbValueDef($rsnew, ew_UnFormatDateTime($psacar_car->created_date->CurrentValue, 5, FALSE), ew_CurrentDate());

		// modified_date
		$psacar_car->modified_date->SetDbValueDef($rsnew, ew_UnFormatDateTime($psacar_car->modified_date->CurrentValue, 5, FALSE), ew_CurrentDate());

		// Call Row Inserting event
		$bInsertRow = $psacar_car->Row_Inserting($rsnew);
		if ($bInsertRow) {
			$conn->raiseErrorFn = 'ew_ErrorFn';
			$AddRow = $conn->Execute($psacar_car->InsertSQL($rsnew));
			$conn->raiseErrorFn = '';
		} else {
			if ($psacar_car->CancelMessage <> "") {
				$this->setMessage($psacar_car->CancelMessage);
				$psacar_car->CancelMessage = "";
			} else {
				$this->setMessage($Language->Phrase("InsertCancelled"));
			}
			$AddRow = FALSE;
		}
		if ($AddRow) {
			$psacar_car->id->setDbValue($conn->Insert_ID());
			$rsnew['id'] = $psacar_car->id->DbValue;

			// Call Row Inserted event
			$psacar_car->Row_Inserted($rsnew);
		}
		return $AddRow;
	}

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Page Redirecting event
	function Page_Redirecting(&$url) {

		// Example:
		//$url = "your URL";

	}

	// Message Showing event
	function Message_Showing(&$msg) {

		// Example:
		//$msg = "your new message";

	}

	// Custom validate event
	// Form Custom Validate event
	function Form_CustomValidate(&$CustomError) {

		// Return error message in CustomError
		return TRUE;
	}
}
?>
